import com.atguigu.spring.proxy.Calculator;
import com.atguigu.spring.proxy.CalculatorImpl;
import com.atguigu.spring.proxy.CalculatorStaticProxy;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
/**
 * 动态代理有两种：
 * 1、jdk动态代理，要求必须有接口，最终生成的代理类和目标类实现相同的接口
 * 在com.sun.proxy包下，类名为$proxy2
 * 2、cglib动态代理，最终生成的代理类会继承目标类，并且和目标类在相同的包下
 */
public class testDynamicProxy {

     @Test
     public void staticTest(){
         CalculatorStaticProxy proxy = new CalculatorStaticProxy(new CalculatorImpl());
        proxy.add(1, 2);
     }


     @Test
     public void dyTest(){
         ProxyFactory proxyFactory = new ProxyFactory(new CalculatorImpl());
         Calculator proxy = (Calculator) proxyFactory.getProxy();
         proxy.div(10,2);
     }

}
